package com.ymatou.iapi.godfreightmgr.testcase;

import java.util.Arrays;
import java.util.List;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.ymatou.iapi.godfreightmgr.parameter.CreateCollectionGoodsAddressBean;
import com.ymatou.iapi.godfreightmgr.parameter.GetDeliveryPatternConfigBeanBySellerids;
import com.ymatou.iapi.godfreightmgr.service.GetDeliveryPatternConfigBySellerIdsCall;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.*;
import com.ymt.utils.tag.*;
import com.ymttest.business.service.GodfreightmgrService;
import com.ymttest.business.service.shenqi.GodmchManageCallService;
/**
*商户配送开关查询
*FreeMaker Template自动生成代码
*/
@TestSuite
public class Ts_GetDeliveryPatternConfigBySellerIds{
	private static GetDeliveryPatternConfigBeanBySellerids GetDeliveryPatternConfigBySellerIdsBean;
	private static GetDeliveryPatternConfigBySellerIdsCall GetDeliveryPatternConfigBySellerIdsCall;
	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("商户配送开关查询");
	}

	@Before
	public void caseUp() {
		GetDeliveryPatternConfigBySellerIdsBean=new GetDeliveryPatternConfigBeanBySellerids();
		GetDeliveryPatternConfigBySellerIdsCall=new GetDeliveryPatternConfigBySellerIdsCall();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(GetDeliveryPatternConfigBySellerIdsCall.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_GetDeliveryPatternConfigBySellerIds_001() {
		Logger.start(true,"商户配送开关查询查询成功");
		try {
			Integer mchId_channl = GodmchManageCallService.CreateSellerMch();
            //开启运营
            GodfreightmgrService.setCollectionGoodsByAdminCall(mchId_channl, true);
            //添加一个自提地址
            CreateCollectionGoodsAddressBean createcollectiongoodsaddressBean = GodfreightmgrService.initCreateCollectionGoodsAddressBean(mchId_channl);
            int addressId = GodfreightmgrService.createcollectiongoodsaddressCall(createcollectiongoodsaddressBean);
            GetDeliveryPatternConfigBySellerIdsBean.setSellerIds( Arrays.asList(mchId_channl)); 
			GetDeliveryPatternConfigBySellerIdsCall.setData(GetDeliveryPatternConfigBySellerIdsBean);
			GetDeliveryPatternConfigBySellerIdsCall.callService();			
			Logger.verifyEquals("200", GetDeliveryPatternConfigBySellerIdsCall.getString("code"), "验code");
			Logger.verifyEquals(true, GetDeliveryPatternConfigBySellerIdsCall.getJsonObject().get("data").getAsJsonArray().get(0).getAsJsonObject().get("enableCollectionGoods").getAsBoolean(), "enableCollectionGoods");
			Logger.verifyEquals(true, GetDeliveryPatternConfigBySellerIdsCall.getJsonObject().get("data").getAsJsonArray().get(0).getAsJsonObject().get("expressDelivery").getAsBoolean(), "expressDelivery");
			Logger.verifyEquals(false, GetDeliveryPatternConfigBySellerIdsCall.getJsonObject().get("data").getAsJsonArray().get(0).getAsJsonObject().get("collectionGoods").getAsBoolean(), "collectionGoods");
			Logger.verifyEquals(mchId_channl, GetDeliveryPatternConfigBySellerIdsCall.getJsonObject().get("data").getAsJsonArray().get(0).getAsJsonObject().get("sellerId").getAsInt(), "sellerId");
			Logger.verifyEquals(false, GetDeliveryPatternConfigBySellerIdsCall.getJsonObject().get("data").getAsJsonArray().get(0).getAsJsonObject().get("manualEdit").getAsBoolean(), "manualEdit");
			
			GodfreightmgrService.setCollectionGoodsBySellerCall(mchId_channl, true);
			GetDeliveryPatternConfigBySellerIdsBean.setSellerIds( Arrays.asList(mchId_channl)); 
			GetDeliveryPatternConfigBySellerIdsCall.setData(GetDeliveryPatternConfigBySellerIdsBean);
			GetDeliveryPatternConfigBySellerIdsCall.callService();			
			Logger.verifyEquals("200", GetDeliveryPatternConfigBySellerIdsCall.getString("code"), "验code");
			Logger.verifyEquals(true, GetDeliveryPatternConfigBySellerIdsCall.getJsonObject().get("data").getAsJsonArray().get(0).getAsJsonObject().get("enableCollectionGoods").getAsBoolean(), "enableCollectionGoods");
			Logger.verifyEquals(true, GetDeliveryPatternConfigBySellerIdsCall.getJsonObject().get("data").getAsJsonArray().get(0).getAsJsonObject().get("expressDelivery").getAsBoolean(), "expressDelivery");
			Logger.verifyEquals(true, GetDeliveryPatternConfigBySellerIdsCall.getJsonObject().get("data").getAsJsonArray().get(0).getAsJsonObject().get("collectionGoods").getAsBoolean(), "collectionGoods");
			Logger.verifyEquals(mchId_channl, GetDeliveryPatternConfigBySellerIdsCall.getJsonObject().get("data").getAsJsonArray().get(0).getAsJsonObject().get("sellerId").getAsInt(), "sellerId");
			Logger.verifyEquals(true, GetDeliveryPatternConfigBySellerIdsCall.getJsonObject().get("data").getAsJsonArray().get(0).getAsJsonObject().get("manualEdit").getAsBoolean(), "manualEdit");
			
			GodfreightmgrService.setExpressDeliveryBySellerCall(mchId_channl, false);
			GetDeliveryPatternConfigBySellerIdsBean.setSellerIds( Arrays.asList(mchId_channl)); 
			GetDeliveryPatternConfigBySellerIdsCall.setData(GetDeliveryPatternConfigBySellerIdsBean);
			GetDeliveryPatternConfigBySellerIdsCall.callService();			
			Logger.verifyEquals("200", GetDeliveryPatternConfigBySellerIdsCall.getString("code"), "验code");
			Logger.verifyEquals(true, GetDeliveryPatternConfigBySellerIdsCall.getJsonObject().get("data").getAsJsonArray().get(0).getAsJsonObject().get("enableCollectionGoods").getAsBoolean(), "enableCollectionGoods");
			Logger.verifyEquals(false, GetDeliveryPatternConfigBySellerIdsCall.getJsonObject().get("data").getAsJsonArray().get(0).getAsJsonObject().get("expressDelivery").getAsBoolean(), "expressDelivery");
			Logger.verifyEquals(true, GetDeliveryPatternConfigBySellerIdsCall.getJsonObject().get("data").getAsJsonArray().get(0).getAsJsonObject().get("collectionGoods").getAsBoolean(), "collectionGoods");
			Logger.verifyEquals(mchId_channl, GetDeliveryPatternConfigBySellerIdsCall.getJsonObject().get("data").getAsJsonArray().get(0).getAsJsonObject().get("sellerId").getAsInt(), "sellerId");
			Logger.verifyEquals(true, GetDeliveryPatternConfigBySellerIdsCall.getJsonObject().get("data").getAsJsonArray().get(0).getAsJsonObject().get("manualEdit").getAsBoolean(), "manualEdit");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P2.class})
	@TestCase
	public void Tc_GetDeliveryPatternConfigBySellerIds_002() {
		Logger.start(true,"不输入sellerIds失败");
		try {
			GetDeliveryPatternConfigBySellerIdsCall.setData(GetDeliveryPatternConfigBySellerIdsBean);
			GetDeliveryPatternConfigBySellerIdsCall.callService();			
			Logger.verifyEquals("400", GetDeliveryPatternConfigBySellerIdsCall.getString("code"), "验code");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P2.class})
	@TestCase
	public void Tc_GetDeliveryPatternConfigBySellerIds_003() {
		Logger.start(true,"输入不存在sellerIds返回默认值");
		try {
			GetDeliveryPatternConfigBySellerIdsBean.setSellerIds(Arrays.asList(1));
			GetDeliveryPatternConfigBySellerIdsCall.setData(GetDeliveryPatternConfigBySellerIdsBean);
			GetDeliveryPatternConfigBySellerIdsCall.callService();			
			Logger.verifyEquals("200", GetDeliveryPatternConfigBySellerIdsCall.getString("code"), "验code");
			Logger.verifyEquals(false, GetDeliveryPatternConfigBySellerIdsCall.getJsonObject().get("data").getAsJsonArray().get(0).getAsJsonObject().get("enableCollectionGoods").getAsBoolean(), "enableCollectionGoods");
			Logger.verifyEquals(true, GetDeliveryPatternConfigBySellerIdsCall.getJsonObject().get("data").getAsJsonArray().get(0).getAsJsonObject().get("expressDelivery").getAsBoolean(), "expressDelivery");
			Logger.verifyEquals(false, GetDeliveryPatternConfigBySellerIdsCall.getJsonObject().get("data").getAsJsonArray().get(0).getAsJsonObject().get("collectionGoods").getAsBoolean(), "collectionGoods");
			Logger.verifyEquals(GetDeliveryPatternConfigBySellerIdsBean.getSellerIds().get(0), GetDeliveryPatternConfigBySellerIdsCall.getJsonObject().get("data").getAsJsonArray().get(0).getAsJsonObject().get("sellerId").getAsInt(), "sellerId");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P2.class})
	@TestCase
	public void Tc_GetDeliveryPatternConfigBySellerIds_004() {
		Logger.start(true,"输入运营开启再关闭sellerIds返回默认值");
		try {
			Integer mchId_channl = GodmchManageCallService.CreateSellerMch();
			CreateCollectionGoodsAddressBean createcollectiongoodsaddressBean = GodfreightmgrService.initCreateCollectionGoodsAddressBean(mchId_channl);
			int addressId = GodfreightmgrService.createcollectiongoodsaddressCall(createcollectiongoodsaddressBean);
			GodfreightmgrService.setCollectionGoodsByAdminCall(mchId_channl, true);
			GodfreightmgrService.setCollectionGoodsBySellerCall(mchId_channl, true);
			GodfreightmgrService.setCollectionGoodsByAdminCall(mchId_channl, false);
			GetDeliveryPatternConfigBySellerIdsBean.setSellerIds( Arrays.asList(mchId_channl)); 
			GetDeliveryPatternConfigBySellerIdsCall.setData(GetDeliveryPatternConfigBySellerIdsBean);
			GetDeliveryPatternConfigBySellerIdsCall.callService();			
			Logger.verifyEquals("200", GetDeliveryPatternConfigBySellerIdsCall.getString("code"), "验code");
			Logger.verifyEquals(false, GetDeliveryPatternConfigBySellerIdsCall.getJsonObject().get("data").getAsJsonArray().get(0).getAsJsonObject().get("enableCollectionGoods").getAsBoolean(), "enableCollectionGoods");
			Logger.verifyEquals(true, GetDeliveryPatternConfigBySellerIdsCall.getJsonObject().get("data").getAsJsonArray().get(0).getAsJsonObject().get("expressDelivery").getAsBoolean(), "expressDelivery");
			Logger.verifyEquals(false, GetDeliveryPatternConfigBySellerIdsCall.getJsonObject().get("data").getAsJsonArray().get(0).getAsJsonObject().get("collectionGoods").getAsBoolean(), "collectionGoods");
			Logger.verifyEquals(GetDeliveryPatternConfigBySellerIdsBean.getSellerIds().get(0), GetDeliveryPatternConfigBySellerIdsCall.getJsonObject().get("data").getAsJsonArray().get(0).getAsJsonObject().get("sellerId").getAsInt(), "sellerId");
			Logger.verifyEquals(true, GetDeliveryPatternConfigBySellerIdsCall.getJsonObject().get("data").getAsJsonArray().get(0).getAsJsonObject().get("manualEdit").getAsBoolean(), "manualEdit");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P2.class})
	@TestCase
	
	public void Tc_GetDeliveryPatternConfigBySellerIds_005() {
		Logger.start(true,"商户配送开关查询查询多个数据成功");
		try {
			Integer mchId_channl = GodmchManageCallService.CreateSellerMch();
            //开启运营
            GodfreightmgrService.setCollectionGoodsByAdminCall(mchId_channl, true);
            //添加一个自提地址
            CreateCollectionGoodsAddressBean createcollectiongoodsaddressBean = GodfreightmgrService.initCreateCollectionGoodsAddressBean(mchId_channl);
            int addressId = GodfreightmgrService.createcollectiongoodsaddressCall(createcollectiongoodsaddressBean);
            GodfreightmgrService.setCollectionGoodsBySellerCall(mchId_channl, true);
            
            Integer mchId_chann2l = GodmchManageCallService.CreateSellerMch();
            List<Integer> sellerIds=Arrays.asList(mchId_channl,mchId_chann2l);
			GetDeliveryPatternConfigBySellerIdsBean.setSellerIds( sellerIds); 
			GetDeliveryPatternConfigBySellerIdsCall.setData(GetDeliveryPatternConfigBySellerIdsBean);
			GetDeliveryPatternConfigBySellerIdsCall.callService();			
			Logger.verifyEquals("200", GetDeliveryPatternConfigBySellerIdsCall.getString("code"), "验code");
			Logger.verifyEquals("200", GetDeliveryPatternConfigBySellerIdsCall.getString("code"), "验code");
			Logger.verifyEquals(true, GetDeliveryPatternConfigBySellerIdsCall.getJsonObject().get("data").getAsJsonArray().get(0).getAsJsonObject().get("enableCollectionGoods").getAsBoolean(), "enableCollectionGoods");
			Logger.verifyEquals(true, GetDeliveryPatternConfigBySellerIdsCall.getJsonObject().get("data").getAsJsonArray().get(0).getAsJsonObject().get("expressDelivery").getAsBoolean(), "expressDelivery");
			Logger.verifyEquals(true, GetDeliveryPatternConfigBySellerIdsCall.getJsonObject().get("data").getAsJsonArray().get(0).getAsJsonObject().get("collectionGoods").getAsBoolean(), "collectionGoods");
			Logger.verifyEquals(GetDeliveryPatternConfigBySellerIdsBean.getSellerIds().get(0), GetDeliveryPatternConfigBySellerIdsCall.getJsonObject().get("data").getAsJsonArray().get(0).getAsJsonObject().get("sellerId").getAsInt(), "sellerId");
			Logger.verifyEquals(true, GetDeliveryPatternConfigBySellerIdsCall.getJsonObject().get("data").getAsJsonArray().get(0).getAsJsonObject().get("manualEdit").getAsBoolean(), "manualEdit");
			
			Logger.verifyEquals(false, GetDeliveryPatternConfigBySellerIdsCall.getJsonObject().get("data").getAsJsonArray().get(1).getAsJsonObject().get("enableCollectionGoods").getAsBoolean(), "enableCollectionGoods");
			Logger.verifyEquals(true, GetDeliveryPatternConfigBySellerIdsCall.getJsonObject().get("data").getAsJsonArray().get(1).getAsJsonObject().get("expressDelivery").getAsBoolean(), "expressDelivery");
			Logger.verifyEquals(false, GetDeliveryPatternConfigBySellerIdsCall.getJsonObject().get("data").getAsJsonArray().get(1).getAsJsonObject().get("collectionGoods").getAsBoolean(), "collectionGoods");
			Logger.verifyEquals(GetDeliveryPatternConfigBySellerIdsBean.getSellerIds().get(1), GetDeliveryPatternConfigBySellerIdsCall.getJsonObject().get("data").getAsJsonArray().get(1).getAsJsonObject().get("sellerId").getAsInt(), "sellerId");
			Logger.verifyEquals(false, GetDeliveryPatternConfigBySellerIdsCall.getJsonObject().get("data").getAsJsonArray().get(1).getAsJsonObject().get("manualEdit").getAsBoolean(), "manualEdit");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_GetDeliveryPatternConfigBySellerIds_006() {
		Logger.start(true,"商户配送开关查询查询成功-未设置的商家返回默认配置");
		try {
			Integer mchId_channl = GodmchManageCallService.CreateSellerMch();
			GetDeliveryPatternConfigBySellerIdsBean.setSellerIds( Arrays.asList(mchId_channl)); 
			GetDeliveryPatternConfigBySellerIdsCall.setData(GetDeliveryPatternConfigBySellerIdsBean);
			GetDeliveryPatternConfigBySellerIdsCall.callService();			
			Logger.verifyEquals("200", GetDeliveryPatternConfigBySellerIdsCall.getString("code"), "验code");
			Logger.verifyEquals(false, GetDeliveryPatternConfigBySellerIdsCall.getJsonObject().get("data").getAsJsonArray().get(0).getAsJsonObject().get("enableCollectionGoods").getAsBoolean(), "enableCollectionGoods");
			Logger.verifyEquals(true, GetDeliveryPatternConfigBySellerIdsCall.getJsonObject().get("data").getAsJsonArray().get(0).getAsJsonObject().get("expressDelivery").getAsBoolean(), "expressDelivery");
			Logger.verifyEquals(false, GetDeliveryPatternConfigBySellerIdsCall.getJsonObject().get("data").getAsJsonArray().get(0).getAsJsonObject().get("collectionGoods").getAsBoolean(), "collectionGoods");
			Logger.verifyEquals(mchId_channl, GetDeliveryPatternConfigBySellerIdsCall.getJsonObject().get("data").getAsJsonArray().get(0).getAsJsonObject().get("sellerId").getAsInt(), "sellerId");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
}